package com.LeeCode;

/**
 * 统计范围内的元音字符串数
 */

public class Code2599 {
    public static void main(String[] args) {

    }

    public int[] vowelStrings(String[] words, int[][] queries) {
        int n = queries.length, len = words.length;
        String vowels = "aeiou";
        int[] preSum = new int[len + 1];
        for (int i = 0; i < len; i++) {
            if (vowels.indexOf(words[i].charAt(0)) != -1 &&
                    vowels.indexOf(words[i].charAt(words[i].length() - 1)) != -1) {
                preSum[i + 1] = preSum[i] + 1;
            } else {
                preSum[i + 1] = preSum[i];
            }
        }

        int[] ans = new int[n];
        for (int i = 0; i < n; i++) {
            ans[i] = preSum[queries[i][1] + 1] - preSum[queries[i][0]];
        }

        return ans;
    }
}
